#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>

int fib(int n)
{
  //base cases
  if(n<=1)
    return n;
  //recursive cases
  else
    return fib(n-1)+fib(n-2);
}

int main(int argc, char *argv[])
{
  int n,result;
  time_t start_time,end_time;
  //initialize n
  if(argc == 2){
    n = atoi(argv[1]);
  }
  else{
    puts("usage: fib n");
    return 1;
  }
  assert(n>=0);

  start_time = time(NULL);
  result = fib(n);
  end_time = time(NULL);

  printf("fib(%d) is %d\n",n, result);
  printf("start:%ld\t end:%ld\n",start_time,end_time);
  printf("%f\n",difftime(end_time,start_time) );
  return 0;
}
